package cn.dancepeak.user.controller;

import cn.dancepeak.exception.BusinessException;
import cn.dancepeak.user.domain.UserParam;
import cn.dancepeak.user.service.IUserParamServiceImpl;
import cn.dancepeak.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/userParam")
@Slf4j
public class UserParamController {
    @Autowired
    private IUserParamServiceImpl userParamService;

    //查数据库Param表返回所有
    @GetMapping("/all")
    public R<Map<String,String>> getAll(){
        try {
            Map<String,String> map = userParamService.getAll();
            return R.ok(map);
        } catch (BusinessException e) {
            log.info("查询数据库Param表异常：{}",e.getMessage());
            return R.fail(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            log.info("查询数据库Param表系统异常：{}",e.getMessage());
            return R.fail(e.getMessage());
        }
    }

}
